<?php
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();
if (1 != $TS_USER['isadmin'])
{
	tsNotice('没有权限执行该操作');
}
$askid = intval($_GET['askid']);

//删除该问题分类对应分类表
$questionstr = $new['ask']->find('ask_topic', array('askid'=>$askid));

//删除先前的分类
$questionCate = $new['ask']->findAll('ask_topic_cate', array('askid'=>$askid));
foreach ($questionCate as $value)
{
	//更改分类数
	$new['ask']->reduce_cate_one($value['cateid']);
}
$new['ask']->delete('ask_topic_cate', array('askid'=>$askid));

if(0 != $questionstr['groupid'])
{
	//删除之前小组同步的问题
	$new['ask']->delete('group_topics', array(
			'typeid'=>0,
			'userid'=>$userid,
			'groupid'=>$questionstr['groupid'],
			'askid'=>$askid
	));
}

//删除问题
$new['ask']->delete('ask_topic', array('askid'=>$askid));
header("Location:".tsUrl('ask'));